<%
	if StatusButton::Hooks.is_open?(@project)
%>
<tr><th class="status"><%= l(:field_status) + "-->" %></th><td class="status" colspan=3><%
# Returns an array of statuses that user is able to apply
def all_new_statuses_allowed_to(issue)
	user = User.current
	old_statuses = []
	statuses = [issue.status].compact
	
	# check all reachables status for all roles the user owns
	while (old_statuses != statuses)
		new_statuses = statuses - old_statuses
		old_statuses = statuses
		new_statuses.each do |s|
			statuses += s.find_new_statuses_allowed_to(
				user.admin ? Role.all : user.roles_for_project(issue.project),
				issue.tracker,
				issue.author == user,
				user.id == issue.assigned_to_id
			)
		end
		statuses = statuses.compact.uniq.sort
	end
	issue.blocked? ? statuses.reject {|s| s.is_closed?} : statuses
end
plugin = Redmine::Plugin.find(:status_button)
setting = Setting["plugin_#{plugin.id}"] || plugin.settings[:default]
allowed_statuses = setting[:check_all_status] ? all_new_statuses_allowed_to(@issue) : @issue.new_statuses_allowed_to()
for status in @issue.tracker.issue_statuses
	if @issue.status == status
		%><b>[<%= status.name %>]</b>&emsp;<%
	else
		%>[<%= link_to_if allowed_statuses.include?(status),
						status.name, "javascript:make_status(#{status.id})" %>]&emsp;<%
	end
end
%></td></tr>
<%= javascript_include_tag "status_button.js", :plugin => 'status_button' %>
<%
	end
%>